<?php
require_once('Configuracion.inc.php');
include(BASE_FRAMEWORK.'/Login.class.php');

if (DB_ACTIVE)
{
    include(BASE_FRAMEWORK . '/Connection.inc.php');
}
$login = new Login();
$login->Get_Session();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
	<title>Subiendo...</title>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<script language="Javascript">
	function actualizar()
	{
		window.opener.location.reload(true);
	}
</script>
<body>
<?php

//$server = '/www/intoxicadosweb.com.ar/htdocs';
//$server = 'D:/teatro/htdocs';
$path_original =  SITE_REAL_PATH.'/img/popups/';

$popup = time() . $_FILES['foto']['name'];
$section = $_REQUEST['section'];
$link = $_REQUEST['link'];
$ancho = $_REQUEST['ancho'];
$alto  = $_REQUEST['alto'];

$imagen_subida = move_uploaded_file($_FILES['foto']['tmp_name'], $path_original . $popup);
if($imagen_subida)
{
	mysql_query("insert into popups (section, popup, link, ancho, alto) values('$section', '$popup', '$link', '$ancho', '$alto')", $conn);
	$error = mysql_error($conn);
	if(!empty($error))
	{
		header('location: ?page=Popup&error=4');
		exit();
	}
	//echo "$i SI!<br>";
	?>
	<script language="Javascript">
		self.window.close();
		actualizar();
	</script>
	<?
}
else
{
	print($imagen_subida);
}
?>
</body>
</html>